#include <stdint.h>
uint32_t djb2_hash(unsigned char *str, int size)
{
    uint32_t hash = 5381;
    int i=0;
    for (i=0; i<size;i++) {
        hash = ((hash<<5)+hash) + str[i];
    }
    return hash;
}

uint32_t djb1_hash(unsigned char *str,int size)
{
    uint32_t hash = 5381;
    int i=0;
    for (i=0; i<size;i++) {
        hash = ((hash<<5)+hash)+str[i];
    }
    return hash;
}

uint32_t sdbm_hash(unsigned char *str, int size)
{
    uint32_t hash = 0;
    int i = 0;
    for (i=0; i<size;i++) {
        hash = str[i] + (hash<<6)+(hash<<16)-hash;
    }
    return hash;
}

uint32_t fnv1a_hash(unsigned char *str,int size)
{
    uint32_t hash  = 2166136261;
    uint32_t prime = 16777619;
    int i = 0;
    for (i=0;i<size;i++) {
        hash ^=str[i];
        hash*=prime;
    }
    return (hash & 0x7FFFFFFF);
}

uint32_t bkdr_hash(unsigned char *str,int size)
{
    uint32_t seed = 131; //31 131 1313 13131 ..etc
    uint32_t hash = 0;
    int i = 0;
    for (i=0;i<size;i++) {
        hash = hash * seed + str[i];
    }
    return (hash & 0x7fffffff);
}
